﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="costsOther.aspx.cs" Inherits="CostsManagement_costsOther" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>其他费用报销单</title>
    <link href="../../Includes/Guide.css" type="text/css" rel="stylesheet" />
    <link href="../../Includes/index.css" type="text/css" rel="stylesheet" />
    <link href="../../Includes/MasterPage.css" type="text/css" rel="stylesheet" />
   <link href="../../Includes/xtree.css" type="text/css" rel="stylesheet" />
    </head>
<script src="../../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="../../Includes/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../Includes/MyJScript.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    //刷新页面
    function reload() {
        //        window.open('ApprovalFlow.aspx', 'main_right');
        parent.$("#main_right").attr("src", 'AuxiliaryManagement/BasicDataManagement/CostsSet/CostsList.aspx');
    }
  
    //显示repeater行数及增行设置
    function display(space) {
        var lineNum = document.getElementById("HiddenField1").value;

        lineNum = space * 1 + lineNum * 1;

        var items = document.getElementsByTagName("tr");
        var num = 0;
        for (var i = 0; i < items.length; i++) {
            if (items[i].title == "itemtr") {
                if (num < lineNum) {
                    items[i].style.display = "block";
                }
                else {
                    items[i].style.display = "none";
                    
                }
                num++;
            }
        }
        document.getElementById("HiddenField1").value = lineNum;
       
    }
    //错误提示
    function chkLogin() {
        alert("错误：未检测到登录信息，请进行登录！");
        window.navigate("../Login.aspx");
    }

    //关闭当前窗口
    function winCancel() {
        parent.PE_FrameTab.CloseCurrentTab();
    }
    //循环repeater 计算申请金额合计数
    function sumApply() {
        sumtotal = 0;
        var rows = document.getElementsByTagName("tr");

        var divs = new Array();

        //var hvalue = document.getElementById("HiddenField3").value;
        var no = 0;
        for (var count = 0; count < rows.length; count++) {

            if (rows[count].title == 'itemtr' && rows[count].style.display == "block") {
                divs[no] = rows[count];
                no = no + 1;
            }
        }

        for (var i = 0; i < no; i++) {
            sumtotal = sumtotal * 1 + divs[i].cells[3].childNodes[0].value * 1;
            //alert(divs[i].childNodes[0].rows[0].cells[1].childNodes[0].value);

        }
        document.getElementById("costorderdetRepeater_ctl11_lblSumAppMoney").innerText = sumtotal;
    }
    //主表项目发生变化，明细行项目统一变化
    function projChange(obj) {
    
        var proj = obj.value;

        var arryProjs = document.getElementById('costorderdetTbl');
        for (i = 1; i < arryProjs.rows.length; i++) {
            arryProjs.rows[i].cells[4].innerText = proj;
                
         }

     }
     //选中行操作
     var selectedTr = null;//选中的行
     function c1(obj) {
         obj.parentNode.parentNode.style.backgroundColor = 'gray'; //把点到的那一行变希望的颜色; 
         if (selectedTr != null) selectedTr.style.removeAttribute("backgroundColor");
         if (selectedTr == obj.parentNode.parentNode) selectedTr = null; //加上此句，以控制点击变白，再点击反灰
         else selectedTr = obj.parentNode.parentNode;
     } 
     

     /*删除选中行*/
     function del() {
         if (selectedTr != null) {
             if (confirm("确定要删除选中行吗?")) {
                 var items = document.getElementsByTagName("tr");
                 var itemtrArry = new Array();
                 var num = 0;
                 //统计表格中现有行数
                 for (var i = 0; i < items.length; i++) {
                     if (items[i].title == "itemtr") {


                         num++;
                         itemtrArry[num] = items[i];

                     }
                 }
                 //要删除行的行号
                 var delrownum = selectedTr.cells[0].childNodes[0].innerText;
                 selectedTr.cells[0].childNodes[0].innerText = num; //设置序号为最大值
                 //删除行
                 selectedTr.style.display = "none";
                 //var tbody = selectedTr.parentNode.parentNode;
                 //tbody.removeChild(selectedTr);
                 //tbody.appendChild(selectedTr);
                 var foottr = document.getElementById("foottr");
                 //tbody.insertBefore(selectedTr, foottr);
                 foottr.parentNode.insertBefore(selectedTr, foottr);
                 document.getElementById("HiddenField1").value = document.getElementById("HiddenField1").value - 1;
                 //将删除行下面的序号，上移
                 for (var k = num; k > delrownum; k--) {
                     //获取下面的行的序号控件


                     itemtrArry[k].cells[0].childNodes[0].innerText = itemtrArry[k].cells[0].childNodes[0].innerText - 1;


                 }

             }
         }
         else {
             alert("请选择一行");
         }
     }

</script>
<body onload="display(0)">
    <form id="form1" runat="server">
    <div class="inputbuttondiv">
<asp:Button ID="btnAdd" runat="server" Text="新增" CssClass="inputbutton" />
<asp:Button ID="btnUpd" runat="server" Text="修改" CssClass="inputbutton" 
            onclick="btnUpd_Click" />
<asp:Button ID="btnDel" runat="server" Text="删除" CssClass="inputbutton"   />
<asp:Button ID="btnSave" runat="server" Text="保存" CssClass="inputbutton" 
            onclick="btnSave_Click"   />
<asp:Button ID="btnSub" runat="server" Text="审核" CssClass="inputbutton"              />
<asp:Button ID="btnSendSub" runat="server" Text="送审" CssClass="inputbutton"           />
<asp:Button ID="btnSendSubTrack" runat="server" Text="送审追踪" CssClass="inputbutton"  />
<%--<asp:Button ID="btnAddRows" runat="server" Text="增行" CssClass="inputbutton"    OnClientClick="display(1)"/>
<asp:Button ID="btnDelRows" runat="server" Text="删行" CssClass="inputbutton"    OnClientClick="deltest()" />--%>
<input id="Button1" type="button" value="增行" class = "inputbutton" onclick = "display(1)"/>
<input id="Button2" type="button" value="删行" class = "inputbutton" onclick = "del()"/>
<asp:Button ID="btnHome" runat="server" Text="首页" CssClass="inputbutton"     />
<asp:Button ID="btnFormer" runat="server" Text="前张" CssClass="inputbutton"     />
<asp:Button ID="btnAfter" runat="server" Text="后张" CssClass="inputbutton"     />
<asp:Button ID="btnLast" runat="server" Text="末页" CssClass="inputbutton"     />
<asp:Button ID="btnPrint" runat="server" Text="打印" CssClass="inputbutton"     />
<asp:Button ID="btnClose" runat="server" Text="关闭" CssClass="inputbutton"  OnClientClick="winCancel()" />
</div>
<hr />
<div>

    <table class="item" style="width:90%;">
        <tr>
            <td  colspan="6" class="tdbgTitle">
                <span class="doubleSpan">其 他 费 报 销 单</span></td>
               
        </tr>
        <tr>
            <td class="tdbg1">
                制单日期：</td>
            <td>
                <asp:TextBox ID="txtfilldate" runat="server" CssClass="Wdatetmp" Width="130px"></asp:TextBox>
            </td>
            <td class="tdbg1">
                单据编号：</td>
            <td>
                <asp:TextBox ID="txtsysNo" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
            <td class="tdbg1">
                内部编码：</td>
            <td >
                <asp:TextBox ID="txtinsideNo" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="tdbg1">
                业务日期：</td>
            <td >
                <asp:TextBox ID="txtbusinessDate" runat="server" CssClass="Wdatetmp" 
                    Width="130px" onFocus="WdatePicker({isShowClear:false,readOnly:true})"></asp:TextBox>
            </td>
            <td class="tdbg1">
                所属部门：</td>
            <td >
             <div style=" height:20px;width:130px; position:relative">
               <asp:TextBox ID="txtapplyDept" runat="server" style="position:absolute;left:0px;top:0px;width:110px;"  CssClass="inputtexttmp"></asp:TextBox>
                <asp:DropDownList ID="ddlapplyDept" runat="server" 
                    AutoPostBack="True"  Height="20px" onchange="document.getElementById('txtapplyDept').value=this.options[this.selectedIndex].text"
                    Width="130px" onselectedindexchanged="ddlapplyDept_SelectedIndexChanged">
                    
                </asp:DropDownList>
                </div>
            </td>
            <td class="tdbg1">
                申 请 人：</td>
            <td >
             <div style=" height:20px;width:130px; position:relative">
               <asp:TextBox ID="txtapplyPsn" runat="server" style="position:absolute;left:0px;top:0px;width:110px;"  CssClass="inputtexttmp"></asp:TextBox>
                <asp:DropDownList ID="ddlapplyPsn" runat="server" Width="130px" 
                Height="20px" onchange="document.getElementById('txtapplyPsn').value=this.options[this.selectedIndex].text">
                </asp:DropDownList>
                </div>
            </td>
        </tr>
        <tr>
            <td class="tdbg1">
                结算方式：</td>
            <td>
             <div style=" height:20px;width:130px; position:relative;border-bottom:0px;">
               <asp:TextBox ID="txtaccWay" runat="server" style="position:absolute;left:0px;top:0px;width:110px;bottom:0px;"  CssClass="inputtexttmp"></asp:TextBox>
                <asp:DropDownList ID="ddlaccWay" runat="server" AppendDataBoundItems="true" 
                   Height="20px" onchange="document.getElementById('txtaccWay').value=this.options[this.selectedIndex].text"
                    Width="130px">
                   
                </asp:DropDownList>
                </div>
            </td>
            <td class="tdbg1">
                币&nbsp;&nbsp;&nbsp; 种：</td>
            <td >
             <div style=" height:20px;width:130px; position:relative">
               <asp:TextBox ID="txtcurrency" runat="server" style="position:absolute;left:0px;top:0px;width:110px;"  CssClass="inputtexttmp"></asp:TextBox>
                <asp:DropDownList ID="ddlcurrency" runat="server" 
                    AutoPostBack="True" Height="20px" onchange="document.getElementById('txtcurrency').value=this.options[this.selectedIndex].text"
                    Width="130px">
                    
                </asp:DropDownList>
                </div>
            </td>
            <td class="tdbg1">
                汇&nbsp;&nbsp;&nbsp; 率：</td>
            <td >
                <asp:TextBox ID="txtrate" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="tdbg1">
                借款单号：</td>
            <td>
                <asp:TextBox ID="txtloanNo" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
            <td class="tdbg1">
                借款金额：</td>
            <td >
                <asp:TextBox ID="txtloanMoney" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
            <td class="tdbg1">
                支付金额：</td>
            <td>
                <asp:TextBox ID="txtpayMoney" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="tdbg1">
                附件张数：</td>
            <td >
                <asp:TextBox ID="txtattachNum" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
            <td class="tdbg1">
                项&nbsp;&nbsp;&nbsp; 目：</td>
            <td >
                <asp:TextBox ID="txtproj" runat="server" CssClass="inputtexttmp" 
                    onchange="projChange(this)"></asp:TextBox>
            </td>
            <td class="tdbg1">
                备&nbsp;&nbsp;&nbsp; 注：</td>
            <td >
                <asp:TextBox ID="txtremarks" runat="server" CssClass="inputtexttmp"></asp:TextBox>
            </td>
        </tr>
        </table>
        <table><tr>
            <td align="left" colspan="6">
               <%-- <asp:Panel ID="Panel1" runat="server" Height="300px" ScrollBars="Both"
                    Width="90%">--%>
                  <div ID="h" runat="server" name="h" 
                                class="repeaterDiv" title="aa">
                   <%-- <table style="width:840px;">
                        <tr>
                            <td align="center" style="width:60px" class="repeaterHeadTdbg">
                                序号</td>
                           
                            <td align="center" style="width:120px" class="repeaterHeadTdbg">
                                摘 要</td>
                            <td align="center" style="width:120px" class="repeaterHeadTdbg">
                                申请金额</td>
                                 <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                     月度可用预算</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                累计可用预算</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                年度可用预算</td>
                            <td align="center" style="width:200px" class="repeaterHeadTdbg">
                                备&nbsp;&nbsp;&nbsp; 注</td>
                        </tr>
                    </table>--%>
                    <asp:Repeater ID="costorderdetRepeater" runat="server" 
                          onitemdatabound="costorderdetRepeater_ItemDataBound"><%--onitemdatabound="costorderdetRepeater_ItemDataBound"--%>
                        <HeaderTemplate>
                        <table border="1" cellpadding="0" cellspacing="0" width="95%" class="repeaterTable" id="costorderdetTbl">
                        <tr>
                        <td align="center" style="width:40px" class="repeaterHeadTdbg">
                                序号</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                费用名称</td>
                            <td align="center" style="width:120px" class="repeaterHeadTdbg">
                                摘 要</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                申请金额</td>
                                 <td align="center" style="width:150px" class="repeaterHeadTdbg">
                                费用项目</td>
                                 <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                     月度可用预算</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                累计可用预算</td>
                            <td align="center" style="width:100px" class="repeaterHeadTdbg">
                                年度可用预算</td>
                            <td align="center" style="width:150px" class="repeaterHeadTdbg">
                                备&nbsp;&nbsp;&nbsp; 注</td>
                        </tr>
                        </HeaderTemplate>
                        
                        <ItemTemplate>
                           
                                
                                    <tr title="itemtr" style="display:block">
                                        <td align="center">
                                            <asp:Label ID="txtLineId" runat="server" Text='<%# Eval("lineId") %>' 
                                                Width="40px" onclick="c1(this)"></asp:Label>
                                        </td>
                                        <td>
                                            <div style=" height:20px;width:100px; position:relative;border-bottom:0px;">
                                            <asp:TextBox ID="txtcostsName" runat="server" style="position:absolute;left:0px;top:0px;width:80px;bottom:0px;"  CssClass="repeaterTableText" Text='<%# Eval("costsid") %>'></asp:TextBox>
                                            <asp:DropDownList ID="ddlcostsName" runat="server" DataSourceID="CostsObjectDataSource" DataTextField="name" DataValueField="id" AppendDataBoundItems="true"
                                                 Height="20px"
                                                Width="100px">
                                                <asp:ListItem Value="0">-选择-</asp:ListItem>
                                            </asp:DropDownList>
                                           
                                            </div>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtdescrip" runat="server"  Width="100px" CssClass="repeaterTableText" Text='<%# Eval("discrip") %>'></asp:TextBox>
                                            <%--<asp:DropDownList ID="ddlcostsName" runat="server" AppendDataBoundItems="true" 
                                                DataSourceID="CostsObjectDataSource" DataTextField="name" DataValueField="code" 
                                                Width="100px">
                                                <asp:ListItem Value="-1">-选择-</asp:ListItem>
                                            </asp:DropDownList>--%>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtapplyMoney" runat="server" CssClass="repeaterTableText" 
                                                onblur="sumApply()" onKeyPress="CheckNumbric(this)" 
                                                Text='<%# Eval("applymoney") %>' Width="120px"></asp:TextBox>
                                        </td>
                                         <td>
                                            <asp:TextBox ID="txtProj" runat="server" CssClass="repeaterTableText" 
                                                Text='<%# Eval("projno") %>' Width="150px"></asp:TextBox>
                                        </td>
                                         <td>
                                           <%-- <asp:TextBox ID="TextBox1" runat="server" CssClass="repeaterTableText" 
                                                onblur="sumApply()" 
                                                Text='<%# Eval("applymoney") %>' Width="100px"></asp:TextBox>--%>
                                             <asp:Label ID="lblmonthBu" runat="server" Text="" Width="100px"></asp:Label>
                                        </td>
                                         <td>
                                           <%-- <asp:TextBox ID="TextBox2" runat="server" CssClass="repeaterTableText" 
                                                onblur="sumApply()" 
                                                Text='<%# Eval("applymoney") %>' Width="100px"></asp:TextBox>--%>
                                             <asp:Label ID="lblaccuTotalBu" runat="server" Text="" Width="100px"></asp:Label>
                                        </td>
                                         <td>
                                           <%-- <asp:TextBox ID="TextBox3" runat="server" CssClass="repeaterTableText" 
                                                onblur="sumApply()" 
                                                Text='<%# Eval("applymoney") %>' Width="100px"></asp:TextBox>--%>
                                             <asp:Label ID="lblyearBu" runat="server" Text="" Width="100px"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtdetremarks" runat="server" CssClass="repeaterTableText" 
                                                Text='<%# Eval("remarks") %>' Width="150px"></asp:TextBox>
                                        </td>
                                    </tr>
                                    </ItemTemplate>
                                 <FooterTemplate>
                                     <tr id="foottr">
                                         <td class="repeaterTableText">
                                             合 计
                                         </td>
                                         <td  colspan="2">
                                            
                                         </td>
                                         <td align="center">
                                             <asp:Label ID="lblSumAppMoney" runat="server" Width="100px" CssClass="inputtexttmp"></asp:Label>
                                         </td>
                                          <td colspan="5">
                                          
                                          </td>
                                     </tr>
                                     </table>
                                 </FooterTemplate>
                            
                        
                    </asp:Repeater>
                </div>
            </td>
        </tr>
        
        <tr>
            <td >
                制单人：</td>
            <td >
                <asp:Label ID="lblfillpsn" runat="server" Width="100px" CssClass="inputtexttmp"></asp:Label>
                
            </td>
            <td >
                提交人：</td>
            <td >
                <asp:Label ID="lblauthorpsn" runat="server" Width="100px"  CssClass="inputtexttmp"></asp:Label>
            </td>
            <td >
                审批人：</td>
            <td >
                <asp:Label ID="lblapprovpsn" runat="server" Width="100px"  CssClass="inputtexttmp"></asp:Label>
            </td>
        </tr>
        <tr style="display:none">
            <td >
                审批意见</td>
            <td colspan="5">
                <asp:TextBox ID="txtcheckInfo" runat="server" Height="100px" 
                    TextMode="MultiLine" Width="99%"></asp:TextBox>
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="HiddenField1" runat="server" value="5"/><%--repeater显示控制隐藏域--%>
    <asp:HiddenField ID="pageFlag" runat="server" /><%--控制当前界面为新增或修改状态--%>
    <asp:ObjectDataSource ID="CostsObjectDataSource" runat="server" 
        SelectMethod="GetAllList" TypeName="WCSY.BLL.fg_costsManager"></asp:ObjectDataSource>

</div>
    </form>
</body>
</html>
